<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        .success {
            color: green
        }

        .error {
            color: red;
        }

        .btn {
            width: 200px;
            height: 40px;
            text-align: center;
            line-height: 40px;
        }

        .default {
            background-color: silver;
            color: black;
        }

        .warn {
            background-color: yellow;
            color: black;
        }
    </style>
</head>

<body>
    <div id="app">
        <h3 class="success">样式一</h3>
        <h3 :class="myclass">样式二</h3>
        <div class="btn default">按钮</div>
        <div :class="mybtn">按钮</div>
        <div :class="{btn:true,default:isDefault}">按钮</div>
        <!-- 上面的两种用的多一点 -->
        <div :class="[btn1,btn2]">按钮</div>
        <div :class="myobj">按钮</div>
        <button @click="change">样式的改变</button>
    </div>

</body>
<script>
    new Vue({
        el: "#app",
        data: {
            myclass: "success",
            mybtn: "btn default",
            isDefault: true,
            btn1: "btn",
            btn2: "default",
            myobj: {
                btn: true,
                default: true,
                warn: false
            }
        },
        methods: {
            change() {
                this.myclass = "error";
                this.mybtn = "btn warn";
                this.isDefault = false;
                this.btn2 = "warn";

                this.myobj.default = false;
                this.myobj.warn = true;
            }
        }
    })

</script>

</html>